<template>
  <div class="changeShipMoney">
    <el-form ref="form" :model="formInline" label-width="100px" class="custom-form">
      <el-form-item label="总运费" >
        <el-input
          class="custom-input"
          type="number"
          v-model="zyf"
          readonly
          placeholder="请输入总运费"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="运费增补" >
        <el-input
          type="text"
          v-model="formInline.yfzb"
          placeholder="请输入运费增补"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="运费扣减" >
        <el-input
          type="number"
          v-model="formInline.yfkj"
          placeholder="请输入运费扣减"
        >
        </el-input>
      </el-form-item>
      <el-form-item label>
        <el-button @click="$emit('closeDialog')">取消</el-button>
        <el-button type="primary" @click="sure">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {updateIncreaseAndDecrease} from "@/api/moneyManagment";
export default {
  name: "changeShipMoney",
  props:{
    row: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
    formInline: {
        yfzb:0,
        yfkj:0
      },
      zyf:0,
    };
  },
  mounted(){
      this.initial()
  },
  methods: {
        async initial(){
            this.zyf = this.row.zyf;
            this.formInline.id = this.row.id;
            this.formInline.yfzb = Number(this.row.yfzb);
            this.formInline.yfkj = Number(this.row.yfkj);
            console.log('this.formInline',this.formInline);
            
        },
        async sure(){
            console.log('this.formInline',this.formInline);
            if(this.formInline.yfzb === ''){
                this.$message.error('运费增补不能为空!');
                return;
            }
            if(this.formInline.yfkj === ''){
                this.$message.error('运费扣减不能为空!');
                return;
            }
            let result = await updateIncreaseAndDecrease(this.formInline);
            if(result.code == 200){
                this.$message.success('修改成功');
                setTimeout(()=>{
                    this.$emit('sureDialog');
                },500)
            }
        }
  }
};
</script>

<style lang="scss" scoped>
.changeShipMoney{
}
</style>

